package plugins.system;

import plugins.Plugin;
import main.Room;
import main.User;

/**
 * Shows caller the list of users online on the server.
 */
public class UserlistPlugin extends Plugin {

   @Override
   public void execute(Room room, User user, String command, String text) {
      int i = 1;
      user.dispatch(room.users.size()
            + (room.users.size() == 1 ? " User" : " Users") + " online.");
      for (User thread : room.users) {
         user.dispatch(i + ". " + thread.name);
         i++;
      }
   }
}
